using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace LibGreen.Jabber.ProtocolElements.SaslElements
{
    /// <summary>
    /// Describes the &lt;auth&gt; element
    /// </summary>
    class AuthElement
    {
        /// <summary>
        /// The xmlns of the &lt;auth&gt; element
        /// </summary>
        private static string XMLNS = "urn:ietf:params:xml:ns:xmpp-sasl";

        /// <summary>
        /// Creates a new &lt;auth&gt; element originating from the client
        /// </summary>
        /// <param name="mechanism">The proposed SASL authentication mechanism</param>
        /// <returns>A new &lt;auth&gt; element</returns>
        public static Element Create(string mechanism)
        {
            Dictionary<string, string> attributes = new Dictionary<string, string>(3);
            attributes["mechanism"] = mechanism;
            attributes["xmlns"] = XMLNS;
            return Element.CreateElement("auth", attributes);
        }

        /// <summary>
        /// Creates a new &lt;auth&gt; element originating from the client
        /// </summary>
        /// <param name="mechanism">The proposed SASL authentication mechanism</param>
        /// <param name="base64data">A string of base-64 encoded authentication data</param>
        /// <returns>A new &lt;auth&gt; element</returns>
        public static Element Create(string mechanism, string base64data)
        {
            Dictionary<string, string> attributes = new Dictionary<string, string>(3);
            attributes["mechanism"] = mechanism;
            attributes["xmlns"] = XMLNS;
            return Element.CreateElement("auth", attributes, base64data);
        }

        //private readonly string mechanism;
        //private readonly string base64data;

        /// <summary>
        /// Initializes an AuthElement from a received <see cref="Element"/>
        /// </summary>
        /// <param name="element">The received <see cref="Element"/> containing the &lt;auth&gt; stanza</param>
        public AuthElement(Element element)
        {
        }
    }
}
